﻿using System;
using System.Data.Entity.ModelConfiguration.Configuration;
using ENail.Domain.Core;
using Equation.Enterprise.Framework.Domain.Model;

namespace ENail.Domain.Data.Mapping
{
    public class ReceiptItemMapping : EntityMapping<ReceiptItem>
    {
        public ReceiptItemMapping()
            : base("ReceiptItem")
        {
            Property(x => x.Id).HasColumnName("ReceiptItemId");

            HasRequired(x => x.Receipt).WithMany(x => x.ReceiptItems).Map(x => x.MapKey("ReceiptId"));
            HasRequired(x => x.Assignment).WithOptional().Map(x => x.MapKey("AssignmentId")).WillCascadeOnDelete(true);
        }
    }
}
